package jtest.com.cpi.cornpp.purchaseorder.dao;

import com.cpi.cornpp.purchase.program.exception.PurchaseProgramException;
import com.cpi.cornpp.purchaseorder.dao.PurchaseOrderCostVersionDAO;
import com.cpi.cornpp.purchaseorder.dto.PurchaseOrderCostVersionDTO;

import junit.framework.TestCase;

public class PurchaseOrderCostVersionDAOTest extends TestCase {

	public PurchaseOrderCostVersionDAOTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testDelete() {
		PurchaseOrderCostVersionDAO purchaseOrderCostVersionDAO = null;
		PurchaseOrderCostVersionDTO purchaseOrderCostVersionDTO = null;
		try{
			purchaseOrderCostVersionDAO = new PurchaseOrderCostVersionDAO();
			purchaseOrderCostVersionDTO = new PurchaseOrderCostVersionDTO();
			purchaseOrderCostVersionDTO.setPurchaseOrderVersionId(new Integer(1196));
			purchaseOrderCostVersionDTO.setCostElementId(new Integer(1));
			purchaseOrderCostVersionDAO.delete(purchaseOrderCostVersionDTO);
		}catch(PurchaseProgramException purchaseProgramException){
			fail(purchaseProgramException.getMessage());
		}
	}
	
	public void testExistsCharge() {
		PurchaseOrderCostVersionDAO purchaseOrderCostVersionDAO = null;
		PurchaseOrderCostVersionDTO purchaseOrderCostVersionDTO = null;
		boolean exists= false;
		try{
			purchaseOrderCostVersionDAO = new PurchaseOrderCostVersionDAO();
			purchaseOrderCostVersionDTO = new PurchaseOrderCostVersionDTO();
			purchaseOrderCostVersionDTO.setPurchaseOrderVersionId(new Integer(1196));
			purchaseOrderCostVersionDTO.setCostElementId(new Integer(1));
			exists = purchaseOrderCostVersionDAO.existsCharge(purchaseOrderCostVersionDTO);
			assertFalse(exists);
			
			purchaseOrderCostVersionDTO = new PurchaseOrderCostVersionDTO();
			purchaseOrderCostVersionDTO.setPurchaseOrderVersionId(new Integer(1196));
			purchaseOrderCostVersionDTO.setCostElementId(new Integer(9));
			exists = purchaseOrderCostVersionDAO.existsCharge(purchaseOrderCostVersionDTO);
			assertTrue(exists);
			
		}catch(PurchaseProgramException purchaseProgramException){
			fail(purchaseProgramException.getMessage());
		}
	}
}